// 验证邮箱的规则
let checkEmail = (rule, value, cb) => {
  if (!value) return cb()
  // 验证邮箱的正则表达式
  const regEmail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/
  if (regEmail.test(value)) {
    // 合法的邮箱
    return cb()
  }
  cb(new Error('请输入合法的邮箱'))
}
// 香港-验证手机号的规则
let HKAndMacaoContact = (rule, value, cb) => {
  if (!value) return cb()
  // 验证手机号的正则表达式
  const regMobile = /^([5|6|8|9])[0-9]{8}$/
  if (regMobile.test(value)) {
    return cb()
  }
  cb(new Error('请输入合法的手机号'))
}
// 内地-验证手机号的规则
let checkMobile = (rule, value, cb) => {
  if (!value) return cb()
  // 验证手机号的正则表达式
  const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
  if (regMobile.test(value)) {
    return cb()
  }
  cb(new Error('请输入合法的手机号'))
}
// ------------------------ 保养预约规则-开始 ------------------------
export function rulesMaintain(e) {
  return {
    name: {
      rules: [
        {
          required: true,
          errorMessage: '姓名不能为空！',
        },
        {
          minLength: 2,
          errorMessage: '姓名至少有{minLength}个字符',
        },
      ],
    },
    phone_no: {
      rules: [
        {
          required: true,
          errorMessage: '电话不能为空！',
        },
        {
          minLength: e ? 8 : 11,
          errorMessage: '请填写正确手机号码！',
        },
        {
          maxLength: e ? 8 : 11,
          errorMessage: '请填写正确手机号码！',
        },
        // {
        //   minLength: 11,
        //   errorMessage: '请填写正确手机号码！',
        // },
      ],
    },
    curr_kilo: {
      rules: [
        {
          required: true,
          errorMessage: '当前里程不能为空！',
        },
        {
          format: 'number',
          errorMessage: '车龄只能输入数字',
        },
      ],
    },
    car_id: {
      rules: [
        {
          required: true,
          errorMessage: '车牌号不能为空！',
        },
        {
          minLength: 7,
          errorMessage: '请输入完整车牌号',
        },
      ],
    },
    appoint_time: {
      rules: [
        {
          required: true,
          errorMessage: '上门日期不能为空！',
        },
        {
          minLength: 13,
          errorMessage: '请完整填写的上门时间！',
        },
      ],
    },
    service_type: {
      rules: [
        {
          required: true,
          errorMessage: '服务类型不能为空！',
        },
      ],
    },
    company: {
      rules: [
        {
          required: true,
          errorMessage: '服务中心不能为空！',
        },
      ],
    },
  }
}
// ------------------------ 试驾预约规则-开始 ------------------------
export function rulesTestDrive(e) {
  return {
    name: {
      rules: [
        {
          required: true,
          errorMessage: '姓名不能为空！',
        },
        {
          minLength: 2,
          errorMessage: '姓名至少有{minLength}个字符',
        },
      ],
    },
    way: {
      rules: [
        {
          required: true,
          errorMessage: '预约方式不能为空！',
        },
      ],
    },
    visit_time: {
      rules: [
        {
          required: true,
          errorMessage: '请选择预约时间',
        },
      ],
    },
    phone_no: {
      rules: [
        {
          required: true,
          errorMessage: '手机号不能为空5！',
        },
        {
          minLength: e ? 8 : 11,
          errorMessage: '请填写正确手机号码！',
        },
        {
          maxLength: e ? 8 : 11,
          errorMessage: '请填写正确手机号码！',
        },
        // {
        //   validateFunction: e ? HKAndMacaoContact() : checkMobile()
        // }
        // {
        //   validateFunction: (rule, value, data, callback) => {

        //     if (e) {
        //       HKAndMacaoContact('请填写正确手机号码1！')
        //     } else {
        //       checkMobile('请填写正确手机号码2！')
        //     }
        //     return true
        //   }
        // }

        // {
        //   validateFunction: function (rule, value, data, callback) {
        //     console.log('object :>> ', value);
        //     if (value.length < 2) {
        //       callback('请至少勾选两个兴趣爱好')
        //     }
        //     // if (!value) return callback()
        //     // 验证手机号的正则表达式
        //     const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
        //     if (regMobile.test(value)) {
        //       return callback()
        //     }
        //     callback(new Error('请输入合法的手机号'))
        //     return true
        //   }
        // }
      ],
    },
    email: {
      rules: [
        {
          required: true,
          errorMessage: '邮箱不能为空！',
        },
        {
          format: 'email',
          errorMessage: '请输入正确的邮箱地址',
        }]
    },
    address: {
      rules: [
        {
          required: true,
          errorMessage: '地址不能为空！',
        },
      ],
    },
    curr_car_model: {
      rules: [
        {
          required: true,
          errorMessage: '现有车型不能为空！',
        },
      ],
    },
    car_age: {
      rules: [
        {
          required: true,
          errorMessage: '车龄不能为空！',
        },
        {
          format: 'number',
          errorMessage: '车龄只能输入数字',
        },
      ],
    },
    industry: {
      rules: [
        {
          required: true,
          errorMessage: '行业不能为空！',
        },
        {
          minLength: 2,
          errorMessage: '行业至少有{minLength}个字符',
        },
      ],
    },
    car_model: {
      rules: [
        {
          required: true,
          errorMessage: '现在车型不能为空！',
        },
      ],
    },
    company: {
      rules: [
        {
          required: true,
          errorMessage: '体验中心不能为空！',
        },
      ],
    },
  }
}
// ------------------------ 购车计算规则-开始 ------------------------
export let rulesCartCompute = {
  brand: [
    {
      required: true,
      message: '请选择品牌',
      trigger: ['blur', 'change'],
    },
  ],
  carModel: [
    {
      required: true,
      message: '请选择车型',
      trigger: ['blur', 'change'],
    },
  ],
  guide: [
    // {
    //   required: true,
    //   message: '请输入指导价格',
    //   trigger: ['blur', 'change'],
    // },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  discounts: [
    // {
    //   required: true,
    //   message: '请输入优惠金额',
    //   trigger: ['blur', 'change'],
    // },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  make: [
    {
      required: true,
      message: '请输入成交价格',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  ratio: [
    {
      required: true,
      message: '请输入贷款金额',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  first: [
    {
      required: true,
      message: '请选择贷款时间',
      trigger: ['blur', 'change'],
    },
  ],
  time: [
    {
      required: true,
      message: '请输入月还款',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  rate: [
    {
      required: true,
      message: '请输入利率',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  interest: [
    {
      required: true,
      message: '请输入手续费',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  service: [
    // {
    //   required: true,
    //   message: '请输入手续费',
    //   trigger: ['blur', 'change'],
    // },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  decorate: [
    // {
    //   required: true,
    //   message: '请输入装饰费',
    //   trigger: ['blur', 'change'],
    // },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  othe: [
    // {
    //   required: true,
    //   message: '请输入其它费用',
    //   trigger: ['blur', 'change'],
    // },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  apply: [
    {
      required: true,
      message: '请输入上牌费',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  purchase: [
    {
      required: true,
      message: '请输入购置税预估费',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
  jiajiang: [
    {
      required: true,
      message: '请输入交强费',
      // trigger: ['blur', 'change'],
    },
    // {
    //   type: 'number',
    //   message: '请输入数字金额',
    //   trigger: ['blur', 'change'],
    // },
  ],
  chechuan: [
    {
      required: true,
      message: '请输入车船费',
      // trigger: ['blur', 'change'],
    },
    // {
    //   type: 'number',
    //   message: '请输入数字金额',
    //   trigger: ['blur', 'change'],
    // },
  ],
  shangye: [
    {
      required: true,
      message: '请输入商业保险总额预估(元)',
      trigger: ['blur', 'change'],
    },
    {
      type: 'number',
      message: '请输入数字金额',
      trigger: ['blur', 'change'],
    },
  ],
}
// ------------------------ 汽车价格计算，选择参数-开始 ------------------------
export let selectParam = {
  cartBrand: [
    [
      { value: 2, name: 'ZEEKR' },
    ],
  ],
  downPayment: [
    [
      { value: 1, name: '全款' },
      { value: 0.1, name: '10%' },
      { value: 0.2, name: '20%' },
      { value: 0.3, name: '30%' },
      { value: 0.4, name: '40%' },
      { value: 0.5, name: '50%' },
      { value: 0.6, name: '60%' },
      { value: 0.7, name: '70%' },
      { value: 0.8, name: '80%' },
      { value: 0.9, name: '90%' },
      // { value: 1, name: '100%' },
    ],
  ],
  periods: [
    [
      { value: 0, name: '无贷款' },
      { value: 3, name: '3期' },
      { value: 6, name: '6期' },
      { value: 12, name: '12期' },
      { value: 24, name: '24期' },
      { value: 36, name: '36期' },
      { value: 48, name: '48期' },
      { value: 60, name: '60期' },
    ],
  ],
  // 交强
  jiajiang: [
    [
      { value: '950', name: '家用6座以下950/年' },
      { value: '1100', name: '家用6座以上1100/年' },
    ],
  ],
  // 车船险
  chechuan: [
    [
      { value: '420', name: '1.0-1.6L(含)420元' },
      { value: '480', name: '1.6-2.0L(含)480元' },
      { value: '900', name: '2.0-2.5L(含)900元' },
      { value: '1920', name: '2.5-3.0L(含)1920元' },
    ],
  ],
}
// ------------------------ 会员卡开通申请-开始 ------------------------
export let rulesCardsReg = {
  userName: {
    rules: [
      {
        required: true,
        errorMessage: '姓名不能为空！',
      },
      {
        minLength: 2,
        errorMessage: '姓名至少有{minLength}个字符',
      },
    ],
  },
  phone: {
    rules: [
      {
        required: true,
        errorMessage: '电话不能为空！',
      },
      {
        minLength: 11,
        errorMessage: '请填写正确手机号码！',
      },
    ],
  },
  car_id: {
    rules: [
      {
        required: true,
        errorMessage: '车牌号不能为空！',
      },
      {
        minLength: 7,
        errorMessage: '请输入完整车牌号',
      },
    ],
  },
  chassisNumber: {
    rules: [
      {
        required: true,
        errorMessage: '底盘号不能为空！',
      },
      {
        minLength: 17,
        errorMessage: '请填写17位底盘号！',
      },
    ],
  },
  company_id: {
    rules: [
      {
        required: true,
        errorMessage: '服务门店不能为空！',
      },
    ],
  },
}